package com.wishu.finance.controller;

import com.wishu.finance.config.AjaxResult;
import com.wishu.finance.domain.SaveSfLoanForm;
import com.wishu.finance.service.TJrProductService;
import com.wishu.finance.service.TJrSfLoanService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("loan")
public class JrSfLoanController {

    @Autowired
    TJrProductService tJrProductService;

    @Autowired
    TJrSfLoanService tJrSfLoanService;

    //收房贷提交
    @PostMapping("savesf")
    public AjaxResult savesf(@RequestBody SaveSfLoanForm sfLoanForm) {
        if (sfLoanForm.getPeriods() > sfLoanForm.getPeriodsA()) {
            return AjaxResult.error("借款期限大于合同有效期限");
        }
        tJrSfLoanService.saveLoan(sfLoanForm);
        return AjaxResult.success();
    }
}
